package com.base.util;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import cn.afterturn.easypoi.excel.entity.vo.BaseEntityTypeConstants;
import lombok.Builder;
import lombok.Data;

import java.util.Date;
import java.util.List;

@Data
@Builder
public class ExportDemo {
    @Excel(name = "出单id", orderNum = "1", width = 20,needMerge = true)
    private String orderId;
    @Excel(name = "订单名称", orderNum = "2", width = 20,needMerge = true)
    private String orderName;
    //ExcelCollection的属性name可写可不写，展示效果不一样
    @ExcelCollection(name = "", orderNum = "3")
    private List<Tuan> tuans;

    @Data
    @Builder
    public static class Tuan{
        @Excel(name = "团名称", orderNum = "1", width = 20,needMerge = true)
        private String name;
        @Excel(name = "结束日期", orderNum = "2", width = 20,needMerge = true,exportFormat="yyyy-MM-dd HH:mm:ss")
        private Date endDate;
        @ExcelCollection(name = "", orderNum = "3")
        private List<Good> goods;
    }

    @Data
    @Builder
    public static class Good{
        //type 导出类型 1 是文本 2 是图片,3 是函数,4 是时间, 10 是数字 默认是文本(见:BaseEntityTypeConstants.DOUBLE_TYPE)
        @Excel(name = "商品id", orderNum = "1", width = 20,type = 10)
        private Integer goodId;
        @Excel(name = "商品名称", orderNum = "1", width = 20)
        private String goodName;
    }

}
